<?php 
namespace Api\Controller;
use Think\Controller;

class NewsController extends Controller{
	public function index(){
			$new=M('news');
			$pro=M('product');
			$banner=M('banner');
			$bannerdata=$banner->limit(3)->select();
			$prodata=$pro->limit(4)->select();
			$data=$new->limit(4)->select();

			echo json_encode(['data'=>$data,'prodata'=>$prodata,'bannerdata'=>$bannerdata]);
	}

	public function product(){
		$product=M('product');
		$data=$product->select();

		$product_id=$_POST['product_id'];
		$prodata=$product->where(array('product_id'=>$product_id))->find();
		echo json_encode(['data'=>$data,'prodata'=>$prodata]);
	}

	public function pro_detail(){
		$product=M('product');
		$product_id=$_POST['product_id'];
		$prodata=$product->where(array('product_id'=>$product_id))->find();
		
		echo json_encode(['prodata'=>$prodata]);
	}
	public function new_detail(){
		$news=M('news');
		$news_id=$_POST['new_id'];
		$newdata=$news->where(array('news_id'=>$news_id))->find();
		
		echo json_encode(['newdata'=>$newdata]);
	}
	public function news(){
		$news=M('news');
		$data=$news->select();
		echo json_encode(['data'=>$data]);
}

	public function contact(){
		$contact=M('contact');
		$data=$contact->order('add_time')->find();
		echo json_encode(['data'=>$data]);
	}
}






 ?>